//
// Created by yangchao on 2022/5/13.
// 26. 删除有序数组中的重复项 : https://leetcode.cn/problems/remove-duplicates-from-sorted-array/
//

#include <vector>
using namespace std;

/*双指针*/
class RemoveDuplicates{
public:
    int removeDuplicates(vector<int>& nums) {
        int len = nums.size();
        if (len == 0) return 0;
        int fast = 1, slow = 1;
        while (fast < len) {
            if (nums[fast] != nums[fast-1]) {
                nums[slow] = nums[fast];
                slow++;
            }
            fast++;
        }
        return slow;
    }
};

int main() {
    vector<int> nums{0,0,1,1,1,2,3,3,4};
    RemoveDuplicates re;
    int res = re.removeDuplicates(nums);
}

